extends ../public/layout
block title
    title 购物记录
block content
    if orderList.length
        each order in orderList
            -var status = order.status
            -var text = ''
            input(type="hidden" val="#{order.hasReturn}")
            .am-container.white-background.am-margin-bottom-sm
                .am-g.cart-shop-name.border-bottom-add.md-line-height.border-top-add
                    .am-u-sm-7
                        a(href="/home/#{order.storeId}")
                            i.am-inline-block.shop-icon
                            span.gray-color #{order.store}
                    .am-u-sm-5.am-text-right
                        case status
                            when 0: -text='待付款'
                            when 1
                                if order.hasReturn
                                    -text='售后中'
                                else
                                    -text='待发货'
                            when 2
                                if order.hasReturn
                                    -text='售后中'
                                else
                                    -text='待收货'
                            when 3: -text='已完成'
                            when 5: -text='交易关闭'
                        span.theme-color #{text}
                each product in order.orderProducts
                    a(href="/order/#{order.objectId}")
                        .am-g.cart-shop-pro
                            img.img-responsive(src = "#{__IMAGE_HOST__}#{product.images}")
                            div.order-list
                                p.am-margin-top-0.am-margin-bottom.pro-title #{product.title}
                                p.am-margin-bottom-0
                                    span.md-font ￥
                                        i #{product.price}
                                    span.am-fr ×
                                        i #{product.count}
                .am-g
                    .am-u-sm-12.am-text-right 合计:
                        span.money-color.md-font.money-color ￥#{order.payPrice}
                case status
                    when 0
                        .am-g.border-top-add.border-bottom-add.cart-pro-handle
                            .am-u-sm-12.am-text-right.am-padding-xs
                                a.am-btn.am-radius.pure-gray.am-btn-xs.cancelOrder(data-orderId="#{order.objectId}") 取消订单
                                a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.payOrder(data-orderId="#{order.objectId}" data-price="#{order.payPrice}") 去付款
                    when 2
                        .am-g.border-top-add.border-bottom-add.cart-pro-handle
                            .am-u-sm-12.am-text-right.am-padding-xs
                                a.am-btn.am-radius.pure-gray.am-btn-xs.viewExpress(data-orderId="#{order.objectId}" data-expressCode="#{order.expressCom}", data-expressNO="#{order.expressNO}", data-expressName="#{order.expressName}") 查看物流
                                a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.confirmAccept(data-orderId="#{order.objectId}") 确认收货
                    when 3
                        .am-g.border-top-add.border-bottom-add.cart-pro-handle
                            .am-u-sm-12.am-text-right.am-padding-xs
                                a.am-btn.am-radius.pure-gray.am-btn-xs.viewExpress(data-orderId="#{order.objectId}" data-expressCode="#{order.expressCom}", data-expressNO="#{order.expressNO}", data-expressName="#{order.expressName}") 查看物流
                                a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.deleteOrder(data-orderId="#{order.objectId}") 删除订单
                    when 5
                        .am-g.border-top-add.border-bottom-add.cart-pro-handle
                            .am-u-sm-12.am-text-right.am-padding-xs
                                a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.deleteOrder(data-orderId="#{order.objectId}") 删除订单
    else
        .emptyMsg
            .empty-Order

    #acceptModal.am-modal.am-modal-confirm(tabindex='-1')
        .am-modal-dialog
            .am-modal-bd
                | 确认收货吗
            .am-modal-footer
                span.am-modal-btn(data-am-modal-cancel='') 取消
                span.am-modal-btn(data-am-modal-confirm='') 确认

    #cancelModal.am-modal.am-modal-confirm(tabindex='-1')
        .am-modal-dialog
            .am-modal-bd
                | 确认要取消订单么？
            .am-modal-footer
                span.am-modal-btn(data-am-modal-cancel='') 取消
                span.am-modal-btn(data-am-modal-confirm='') 确认

    #deleteModal.am-modal.am-modal-confirm(tabindex='-1')
        .am-modal-dialog
            .am-modal-bd
                | 确认要删除订单么？
            .am-modal-footer
                span.am-modal-btn(data-am-modal-cancel='') 取消
                span.am-modal-btn(data-am-modal-confirm='') 确认
block javascript
    script(type="text/javascript" src = "/bower_components/amazeui/dist/js/amazeui.min.js")
    script(type="text/javascript" src = "/public/javascripts/orders.js")
    script(type="text/javascript" src = "/public/javascripts/orderModal.js")
    script(type="text/javascript").
        $(function () {
            orders.init();
        });
        $(function () {
            orderHandle.init();
        });



